import request from '@/utils/request'
import { getStoreId } from '@/utils/index'

// 获取员工分页数据
export function userPage(form, pageSize, currentPage) {
  console.log('查询条件', form, pageSize, currentPage)
  return request.post('/base/user/page', {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  })
}
/**
 * 账户起停
 * @param {*} id
 */
export function changeStatus(id) {
  return request.get(`/base/user/status/${id}`)
}
/**
 * 删除账户
 * @param {*} id
 */
export function deleteUser(id) {
  return request.delete(`/base/user/${id}`)
}
/**
 * 新增、修改账户
 * @param {*} id
 */
export function addUserEdit(form) {
  return form.id ? request.put(`/base/user/save`, form) : request.post(`/base/user/save`, form)
}
/**
 * 校验账号
 * @param {*} account
 */
export function checkAccount(account) {
  return request.get(`/base/user/checkAccount/${account}`)
}

/**
 * 查询用户详细信息
 * @param {*} id
 */
export function getUserId(id) {
  return request.get(`/base/user/${id}`)
}
/**
 * 查询当前门店下任职员工
 * @param {*} id
 */
export function getStoreUser() {
  return request.get(`/base/user/getStoreUser/${getStoreId()}`)
}

/**
 * 门店员工搜索
 * @param {*} form
 * @param {*} pageSize
 * @param {*} currentPage
 */
export function baseUserPageStore(form, pageSize, currentPage) {
  return request.post(`/base/user/pageStore`, {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  })
}
/**
 * 登录日志
 * @param {*} form
 * @param {*} pageSize
 * @param {*} currentPage
 */
export function loginLogPage(form, pageSize, currentPage) {
  return request.post(`/loginLog/page`, {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  })
}

/**
 * 获取门店下的可用用户
 * @param {*} id
 */
export function getStoreEnableUser(storeId) {
  return request.get(`/base/user/getStoreUser/${storeId}`)
}

/**
 * 修改自己的密码
 * @param {*} form
 */
export function baseUserPassword(form) {
  return request.put(`/base/user/password`, form)
}

